home *** CD-ROM | disk | FTP | other *** search
QuickBASIC Tokenized Source | 1990-11-30 | 10.9 KB | 162 lines |
- NMALLOCn
- Text+
- BsDFmt
- A0570
- A0570.Put.DiskMsg
- MaxTrackq
- Sectors
- SectSize`
- SECTSIXE
- Indicate
- Bytes=
- Sector1
- OFFSETx
- SEGMENT
- OLD.MAXSECT
- MAXSECT#
- Buffer
- BsdWrit
- Usage
- Drive
- Track
- Write
- Write.Buffer
- Bytes.Sector
- Sectors.Cluster
- Reserved
- Reserved.Sectors
- FAT.Count
- Dir.Entries
- Total
- Total.Sectors
- Media
- Media.Desc
- Sectors.Track
- Head.Count
- Hidden
- Hidden.Sectors
- Sectors.FAT
- diskette
- place
- illegal
- command
- Error
- Error.Routine
- Update
- Update.FAT
- BsdRead
- Copyright (c) 1988 Marcel Madonnae
- QBFORMAT.BAS will format a DS/DD diskette on a 360KB or a 1.2M diskette drive*
- Note that no error checking is done. This means that bad sectors will not
- be flagged in the FAT. *
- The diskette will be usable in every other respect. The bootstrap routine
- used on the Boot sector is fairly standard. You can place yourr
- own bootstrap routine on the diskette, but be aware that each version of
- DOS may have a unique bootstrap routine and different manufacturers will
- have different routines (i.e. COMPAQ DOS bootstrap routines may differ
- from the bootstrap routine supplied by MS-DOS and PC-DOS).
- You can improve on this routine by reading each cluster after it isr
- formatted and marking the FAT if the cluster is bad. You can also
- accept parameters from the DOS prompt and format 1.2M diskettes or
- create your own format. CAUTION - MODIFYING THIS ROUTINE REQIURES
- SOME KNOWLEDGE OF THE DISK BASE TABLE AND THE BIOS PARAMETER BLOCK.
- UNINFORMED MODIFICATIONS CAN RESULT IN UNPREDICTABLE RESULTS
- * N O T E
- This program cannot be used from the DOS prompt without Microsofti
- QuickBasic V4.0 and a registered copy of QBWARE.
- To compile it, at the DOS prompt type:
- bc qbformat;s
- link /ex /noe qbformat,,,brun40 qbware;
- del qbformat.objf
- del qbformat.mapf
- To run it from the QuickBasic development environment, type:
- qb qbformat /l qbware
- [Shift] + F5b
- To execute just type "QBFORMAT" at the DOS promptt
- For Example:
- QBFORMATj
- will format a diskette in drive A:
- Qbformat - Version 1.0 (C) Copyright 1988 AJM Software"
- Use the A drive
- We will now format the diskette in Drive A: as a 9-Sector DS/DD diskette
- Do you wish to continue (Y/N)?
- Format aborted
- Make sure that the Disk Base table is properly initialized
- Default to 360k DS/DD diskr
- The following code should be needed only for AT type machines
- Offset of DBT
- Segment of DBT
- The Disk Base Table is in ROM and cannot be altered"
- Indicate 9 sectors/track
- Initialize buffer area
- Indicate 40 tracks (0-39)
- Indicate 9 sectors/track
- Indicate 512 bytes/sector
- Initialize return code
- ...Formatting CYL "
- TRACK
- You can use the following code to check for bad clusters. It's slow, but
- it does workt
- FOR Sector% = 1 TO Sectors%t
- CALL BsdRead(Buffer$, Drive$, Head%, Track%, Sector%, Rc%)e
- IF Rc% <> 0 THENf
- GOSUB Update.FATf
- END IFU
- NEXT Sector%
- Now setup the root directory. On a DS/DD diskette, the directory resides
- on sectors 6 thru 12. Note that sectors 10-12 are really sectors 1-3*
- on track 0, head 1.2
- ...Initializing directory space"
- Now let's write a fresh FAT. Since 2 FAT's are the DOS standard, we'll
- write two FAT's. They reside on sectors 2-5 of track 0, head 0.
- ...Creating FAT"
- The last thing we need is the boot record.
- First, set up the BIOS parameter block for DS/DD disk
- ...Initializing the BOOT Sector"
- AJM 1988
- Signature
- Move the BPB to the Buffer
- If you want to place a bootstrap routine on the BOOT sector, initialize
- Buffer$ with the appropriate values here. All of this stuff below is
- a machine language bootstrap routine.
- IBMBIO COM"
- IBMDOS COM"
- Non-System disk or disk error$
- Replace and strike any key when ready"
- Disk boot failure$
- (c) AJM Software 1988"
- Restore the old value
- ...All done"
- Remember that this program is intended to be used as a demo"
- only. No error checking was done so any bad clusters will
- not be marked as bad in the FAT. This diskette is usable"
- in all other respects.
- 1 - illegal command
- 2 - sector not foundm
- 3 - write protect error
- 4 - bad sector
- 6 - disk drive door opened (some 1.2M drives only)
- 8 - DMA failure
- 9 - DMA overrun
- 16 - bad CRC:parity check
- 32 - controller malfunction
- 64 - seek failurea
- 128 - time outl
- Illegal command issued
- Sector not found
- Write protect error"
- Bad sector found
- Don't open the drive door during a format"
- DMA failure"
- DMA overrun"
- Bad CRC"
- Controller malfunction
- Seek failure
- Time-out
- Make sure the drive door is closed
- Error
- Format halted
- You can update the FAT here if you want to make your diskette usable
- when it contains bad clusters.
- Bad cluster found - do not use this diskette
-